package com.incar.chuxing.activity;

import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;


import com.incar.chuxing.R;
import com.incar.chuxing.base.BaseActivity;
import com.incar.chuxing.utils.Constants;
import com.incar.chuxing.utils.StatusBarUtil;
import com.incar.chuxing.utils.Toast.ToastCompat;
import com.zhy.autolayout.AutoRelativeLayout;

import butterknife.BindView;
import butterknife.OnClick;

public class ChangeNameActivity extends BaseActivity {


    @BindView(R.id.title_name)
    TextView titleName;
    @BindView(R.id.edt_changeName)
    EditText changeName;
    @BindView(R.id.changeName_pb)
    ProgressBar changeNamePb;
    @BindView(R.id.title_tv_more)
    TextView title_tv_more;
    @BindView(R.id.title_more)
    ImageView title_more;




    @Override
    public int getLayoutId() {
        return R.layout.activity_change_name;
    }

    @Override
    public void initView() {
       // StatusBarUtil.setColor(this, getResources().getColor(R.color.colorPrimaryWhite), 0,true);
        title_more.setVisibility(View.GONE);
        title_tv_more.setVisibility(View.VISIBLE);
        title_tv_more.setText("保存");
         titleName.setText("修改昵称");

        Intent intent = getIntent();
        String name = intent.getStringExtra("name");
        changeName.setText(name);
    }

    @OnClick({R.id.title_back, R.id.save,R.id.iv_clear,R.id.title_tv_more})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.title_back:
                finish();
                break;
            case R.id.iv_clear:
                changeName.setText("");
                break;
            case R.id.title_tv_more:
                if (!TextUtils.isEmpty(changeName.getText().toString())) {
                    Intent intent1 = new Intent();
                    intent1.putExtra("name", changeName.getText().toString());
                    setResult(Constants.REQUEST_CHANGE_INFO, intent1);
                    finish();
                } else {
                    ToastCompat.makeText(getApplicationContext(), "请输入昵称！", Toast.LENGTH_SHORT).show();
                }
                break;
        }
    }
}
